<template>
	<view class="select-coupon-wrap ">
		<view class="coupon-item u-flex u-row-between">
			<view class="item-title">线下会员卡</view>
			<view class="u-flex" @tap="showModal = true">
				<text class="price" v-if="couponList.length">{{ title }}</text>
				<text class="sel-coupon" v-else>暂无线下会员卡</text>
				<!-- <text class="u-iconfont uicon-arrow-right" style="color: #bfbfbf"></text> -->
			</view>
		</view>

		<u-popup v-model="showModal" mode="bottom" :closeable="true" close-icon-pos="top-right" border-radius="30">
			<view class="modal-box page_box">
				<view class="modal-head u-flex u-row-center u-col-center"><text class="head-title">选择线下会员卡</text></view>
				<view class="modal-content content_box u-flex-col u-p-20xxx">
					<u-radio-group v-model="radio" @change="radioGroupChange" width="100%" activeColor="#0099E5">
						<view class="radio-item">
							<u-radio :name="0"><text class="coupon-title u-p-l-10">不使用线下会员卡</text></u-radio>
						</view>
						<view class="radio-item radio-items" v-for="(radio, index) in couponList"
							:key="radio.user_coupons_id">
							<view class="yj">
								线下卡
							</view>
							<view class="" style="display: flex;justify-content: space-between;align-items: center;">
								<view class="" style="">
									<view class="" style="font-size: 30rpx;font-weight: 400;color: #333333;">
										{{radio.store.name}}
									</view>
									<view class=""
										style="font-size: 30rpx;font-weight: 400;color: #333333;margin-top: 20rpx;">
										余额：{{radio.money}}元
									</view>
								</view>
								<view class=""
									style="font-weight: 400;color: #333333;font-size: 60rpx;font-weight: 400;color: #DD3A23;">
									{{radio.discount}}<span style="font-size: 30rpx;">折</span>
								</view>
							</view>
							<view class="" style="margin-top: 56rpx;display: flex;">
								<u-radio :name="index + 1">
									<text class="coupon-title u-p-l-10"
										style="font-size: 24rpx;font-weight: 400;color: #787878;">{{ radio.mobile }}</text>
								</u-radio>
							</view>
						</view>
					</u-radio-group>
				</view>
				<button class="u-reset-button serve-btn" @tap="showModal = false">确定</button>
			</view>
		</u-popup>
	</view>
</template>

<script>
	/**
	 * 选择线下会员卡模态框
	 * @property {Object} couponList - 可用线下会员卡列表数据
	 *
	 */
	export default {
		components: {},
		data() {
			return {
				showModal: false,
				radio: 0,
				title: '选择线下会员卡'
			};
		},
		props: {
			couponList: {
				type: Array,
				default: () => []
			}
		},
		computed: {},
		methods: {
			radioGroupChange(index) {
				this.title = index > 0 ? this.couponList[index - 1].titles : '选择线下会员卡';
				// this.title = index > 0 ? '-￥' + this.couponList[index - 1].amount : '选择线下会员卡';
				this.$emit('change', index - 1);
			}
		}
	};
</script>

<style lang="scss" scoped>
	// 线下会员卡项
	.coupon-item {
		// border-top: 1rpx solid rgba(#dfdfdf, 0.5);
		height: 100rpx;
		background: #fff;
		padding: 0 30rpx;

		.item-title {
			font-size: 28rpx;
			margin-right: 20rpx;
		}

		.price {
			font-size: 26rpx;
			color: #ff0000;
			margin-right: 20rpx;
		}

		.sel-coupon {
			font-size: 26rpx;
			color: #c4c4c4;
			// margin-right: 20rpx;
		}
	}

	// 模态框
	.modal-box {
		width: 750rpx;
		min-height: 700rpx;
		background: #fff;
		background: #F2F2F2;
		padding: 30rpx;

		// 按钮
		.serve-btn {
			width: 690rpx;
			line-height: 80rpx;
			background: linear-gradient(90deg, #0099E5, #0099E5);
			border-radius: 40rpx;
			color: rgba(#fff, 0.9);
			margin-top: 40rpx;
		}

		.radio-item {
			position: relative;
			width: 690rpx;
			margin-bottom: 20rpx;
		}

		.radio-items {
			position: relative;
			width: 690rpx;
			margin-bottom: 20rpx;

			padding: 30rpx;
			padding: 70rpx 30rpx 30rpx 30rpx;
			height: 297rpx;
			background: url($IMG_URL+'/imgs/detail/card.png') no-repeat;
			background-size: 100% 100%;
		}

		.yj {
			position: absolute;
			top: 0;
			left: 0rpx;
			width: 110rpx;
			height: 41rpx;
			line-height: 41rpx;
			background: url($IMG_URL+'/imgs/detail/yj.png') no-repeat;
			background-size: 100% 100%;

			font-size: 24rpx;
			font-weight: 400;
			color: #FFFFFF;
			text-align: center;
		}

		// 标题
		.modal-head {
			margin-bottom: 30rpx;

			.head-title {
				font-size: 32rpx;
				font-weight: bold;
			}
		}
	}
</style>